//
//  DetailCoachViewController.m
//  Frame
//
//  Created by 这是工作本 on 16/3/3.
//  Copyright © 2016年 这是工作本. All rights reserved.
//

#import "DetailCoachViewController.h"

@interface DetailCoachViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UIGestureRecognizerDelegate>
@property (nonatomic, retain) UICollectionView *VcollectionV;
@end

@implementation DetailCoachViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 /255.0 blue:240 / 255.0 alpha:1.0];
    self.navigationItem.title = @"教练详情";
    //隐藏自动返回
    self.navigationItem.hidesBackButton = YES;
    //返回按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"but_an.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonAction:)];
    //设置导航栏颜色
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:29 / 255.0 green:127 / 255.0  blue:140 / 255.0  alpha:1.0];
    
    //设置title颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1.0],NSForegroundColorAttributeName,nil]];
    
    
    //背景
    UIView *nameB = [[UIView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 70 * ScreenHeigth)];
    nameB.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:nameB];
    
    //图片
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(20 * ScreenWidth, 10 * ScreenHeigth, 50 * ScreenWidth, 50 * ScreenHeigth)];
    image.layer.masksToBounds = YES;
    image.layer.cornerRadius = 25 * ScreenWidth;
    image.image = [UIImage imageNamed:@"43543@2x.png"];
    [nameB addSubview:image];
    
    
    //标题名字
    
    UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(image.frame.origin.x + image.frame.size.width + 25 * ScreenWidth, image.frame.origin.y - 10 * ScreenHeigth, 100 * ScreenWidth, 28 * ScreenHeigth)];
    name.text = @"姚明";
    name.font = [UIFont systemFontOfSize:14.0 * ScreenWidth];
    name.textAlignment = NSTextAlignmentLeft;
    name.textColor = [UIColor colorWithRed:29 / 255.0 green:127 / 255.0 blue:140 / 255.0 alpha:1.0];
    [nameB addSubview:name];
    
    //介绍
    
    UILabel *introduce = [[UILabel alloc] initWithFrame:CGRectMake(name.frame.origin.x , name.frame.origin.y + name.frame.size.height - 5 * ScreenHeigth, 200 * ScreenWidth, 24 * ScreenHeigth)];
    introduce.text = @"任教十年";
    introduce.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    introduce.textAlignment = NSTextAlignmentLeft;
    introduce.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameB addSubview:introduce];
    
    
    //评分
    
    UILabel *Score = [[UILabel alloc] initWithFrame:CGRectMake(name.frame.origin.x , name.frame.origin.y + name.frame.size.height + 15 * ScreenHeigth, 200 * ScreenWidth, 24 * ScreenHeigth)];
    Score.text = @"任教科目: 篮球";
    Score.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    Score.textAlignment = NSTextAlignmentLeft;
    Score.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameB addSubview:Score];

    
    
    
    //联系他
    
    UIImageView *Contact = [[UIImageView alloc] initWithFrame:CGRectMake(introduce.frame.origin.x + introduce.frame.size.width + 30 * ScreenWidth, introduce.frame.origin.y , 28 * ScreenWidth, 28 * ScreenHeigth)];
    Contact.image = [UIImage imageNamed:@"2121.png"];
    [nameB addSubview:Contact];

  

    UILabel *Contaction = [[UILabel alloc] initWithFrame:CGRectMake(Contact.frame.origin.x + Contact.frame.size.width + 6 * ScreenWidth , introduce.frame.origin.y + 4 * ScreenHeigth, 100 * ScreenWidth, 24 * ScreenHeigth)];
    Contaction.text = @"联系他";
    Contaction.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    Contaction.textAlignment = NSTextAlignmentLeft;
    Contaction.textColor = [UIColor colorWithRed:29 / 255.0 green:127 / 255.0 blue:140 / 255.0 alpha:1.0];
    [nameB addSubview:Contaction];

    
    //背景
    UIView *nameF = [[UIView alloc] initWithFrame:CGRectMake(0, nameB.frame.origin.y + nameB.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 100 * ScreenHeigth)];
    nameF.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:nameF];

    //授课方式
    
    
    UILabel *class = [[UILabel alloc] initWithFrame:CGRectMake(10 * ScreenWidth , 10 * ScreenHeigth, 70 * ScreenWidth, 30 * ScreenHeigth)];
    class.text = @"授课方式:";
    class.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
    class.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    class.textAlignment = NSTextAlignmentLeft;
    class.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameF addSubview:class];
    
    
    //介绍
    
    UILabel *classIntroduce = [[UILabel alloc] initWithFrame:CGRectMake(class.frame.origin.x , class.frame.origin.y + class.frame.size.height, class.frame.size.width, 24 * ScreenHeigth )];
    classIntroduce.text = @"全日制";
    classIntroduce.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    classIntroduce.textAlignment = NSTextAlignmentLeft;
    classIntroduce.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameF addSubview:classIntroduce];

    
    
    
    
    
    
    //背景
    UIView *nameS = [[UIView alloc] initWithFrame:CGRectMake(0, nameF.frame.origin.y + nameF.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 100 * ScreenHeigth)];
    nameS.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:nameS];

    
    //授课方式
    
    
    UILabel *content = [[UILabel alloc] initWithFrame:CGRectMake(10 * ScreenWidth , 10 * ScreenHeigth, 70 * ScreenWidth, 30 * ScreenHeigth)];
    content.text = @"授课内容:";
    content.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
    content.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    content.textAlignment = NSTextAlignmentLeft;
    content.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameS addSubview:content];
    
    
    //介绍
    
    UILabel *contentIntroduce = [[UILabel alloc] initWithFrame:CGRectMake(class.frame.origin.x , class.frame.origin.y + class.frame.size.height, class.frame.size.width, 24 * ScreenHeigth )];
    contentIntroduce.text = @"扣篮";
    contentIntroduce.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    contentIntroduce.textAlignment = NSTextAlignmentLeft;
    contentIntroduce.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameS addSubview:contentIntroduce];

    
    
    //背景
    UIView *nameT = [[UIView alloc] initWithFrame:CGRectMake(0, nameS.frame.origin.y + nameS.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth)];
    nameT.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:nameT];

    
    UILabel *price = [[UILabel alloc] initWithFrame:CGRectMake(10 * ScreenWidth , 10 * ScreenHeigth, 70 * ScreenWidth, 30 * ScreenHeigth)];
    price.text = @"授课价格";
    price.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
    price.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    price.textAlignment = NSTextAlignmentLeft;
    price.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameT addSubview:price];
    
    
    //介绍
    
    UILabel *priceIntroduce = [[UILabel alloc] initWithFrame:CGRectMake(price.frame.origin.x + price.frame.size.width + 20 * ScreenWidth, class.frame.origin.y + 4 * ScreenHeigth, 200 * ScreenWidth, 24 * ScreenHeigth )];
    priceIntroduce.text = @"每小时300元";
    priceIntroduce.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    priceIntroduce.textAlignment = NSTextAlignmentLeft;
    priceIntroduce.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameT addSubview:priceIntroduce];

    
    //背景
    UIView *nameE = [[UIView alloc] initWithFrame:CGRectMake(0, nameT.frame.origin.y + nameT.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 310 * ScreenHeigth)];
    nameE.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:nameE];

    UILabel *time = [[UILabel alloc] initWithFrame:CGRectMake(10 * ScreenWidth , 10 * ScreenHeigth, 70 * ScreenWidth, 30 * ScreenHeigth)];
    time.text = @"授课时间";
    time.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
    time.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    time.textAlignment = NSTextAlignmentLeft;
    time.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [nameE addSubview:time];
    
    //时间
    
    //纵向collectionView
    UICollectionViewFlowLayout *flowL_V = [[UICollectionViewFlowLayout alloc] init];
    //最小行间距
    flowL_V.minimumLineSpacing = 10 * ScreenWidth;
    //滚动方向
    flowL_V.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    //单位大小
    flowL_V.itemSize = CGSizeMake(60 * ScreenWidth, 80 * ScreenHeigth);
    //与屏幕四边的间距
    flowL_V.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.VcollectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(10, time.frame.origin.y + time.frame.size.height + 5 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 100 * ScreenHeigth) collectionViewLayout:flowL_V];
    //隐藏指示条
    self.VcollectionV.showsHorizontalScrollIndicator = NO;
    //关闭自动偏移
    self.automaticallyAdjustsScrollViewInsets = NO;
    //点击状态栏返回顶部
    self.VcollectionV.scrollsToTop = YES;
    self.VcollectionV.bounces = NO;
    self.VcollectionV.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    ;    
    //签协议
    self.VcollectionV.delegate = self;
    self.VcollectionV.dataSource = self;
    //注册cell
    [self.VcollectionV registerClass:[CoachCollectionViewCell class] forCellWithReuseIdentifier:@"verticalCell"];
    //整页滑动
    
    self.VcollectionV.pagingEnabled = YES;
    
    [nameE addSubview:self.VcollectionV];

    
    //添加全屏右滑动手势
    id target = self.navigationController.interactivePopGestureRecognizer.delegate;
    // 创建全屏滑动手势，调用系统自带滑动手势的target的action方法
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    // 设置手势代理，拦截手势触发
    pan.delegate = self;
    // 给导航控制器的view添加全屏滑动手势
    [self.view addGestureRecognizer:pan];
    // 禁止使用系统自带的滑动手势
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;


    
}




- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
 
        return 8;
    
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
            
        
        
        CoachCollectionViewCell *ver = [collectionView dequeueReusableCellWithReuseIdentifier:@"verticalCell" forIndexPath:indexPath];
        
        ver.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
        
        return ver;
    
}



- (void)leftBarButtonAction:(UIBarButtonItem *)sender
{
    
    
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
